<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>修改用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>

    <link rel="stylesheet" href="../../static/css/font.css" th:href="@{/css/font.css}">
    <link rel="stylesheet" href="../../static/css/xadmin.css" th:href="@{/css/xadmin.css}">
    <script src="../../static/js/jquery-3.2.1.min.js" type="text/javascript" th:src="@{/js/jquery-3.2.1.min.js}"></script>
    <script src="../../static/js/vue.js" type="text/javascript" th:src="@{/js/vue.js}"></script>
    <script src="../../static/lib/layui/layui.js" charset="utf-8" th:src="@{/lib/layui/layui.js}"></script>
    <script type="text/javascript" src="../../static/js/xadmin.js" th:src="@{/js/xadmin.js}"></script>


    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
    <script th:src="@{/bootstrap/js/bootstrap.min.js}" type="text/javascript"></script>

    <style>
        .layui-form-item{
            padding-left: 110px;
        }
        .layui-btn{
            margin-left: 47px;
        }
    </style>

</head>

<body>

<div class="x-body">
    <form class="layui-form">

        <div class="layui-form-item">
            <label for="quContent" class="layui-form-label">
                题目内容
            </label>
            <div class="layui-input-inline">
                <input type="hidden" id="quId" name="quId" th:value="${questionBank.quId}">
<!--                <input type="text" id="quContent" name="quContent" height="50px"-->
<!--                       autocomplete="off" th:value="${questionBank.quContent}" class="layui-input">-->
                <textarea id="quContent" name="quContent"  class="layui-textarea" th:text="${questionBank.quContent}"
                          th:value="${questionBank.quContent}" ></textarea>

            </div>
        </div>

        <div class="layui-form-item">
            <label for="quAoption" class="layui-form-label">
                A:
            </label>
            <div class="layui-input-inline">
                <input type="text" id="quAoption" name="quAoption"  th:value="${questionBank.quAoption}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="quBoption" class="layui-form-label">
                B:
            </label>
            <div class="layui-input-inline">
                <input type="text" id="quBoption" name="quBoption"  th:value="${questionBank.quBoption}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="quCoption" class="layui-form-label">
                C:
            </label>
            <div class="layui-input-inline">
                <input type="text" id="quCoption" name="quCoption"  th:value="${questionBank.quCoption}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="quDoption" class="layui-form-label">
                D:
            </label>
            <div class="layui-input-inline">
                <input type="text" id="quDoption" name="quDoption"  th:value="${questionBank.quDoption}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="quType" class="layui-form-label">
                题型
            </label>
            <div class="layui-input-inline">
                <select id="quType" name="quType">
                    <option value="单选题"  th:selected="${questionBank.quType == '单选题'}">单选题</option>
                    <option value="多选题"  th:selected="${questionBank.quType == '多选题'}">多选题</option>
                    <option value="判断题"  th:selected="${questionBank.quType == '判断题'}">判断题</option>
                </select>
            </div>
        </div>



        <div class="layui-form-item">
            <label for="quScore" class="layui-form-label">
                分数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="quScore" name="quScore" th:value="${questionBank.quScore}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <!-- 年龄框结束位置-->

        <div class="layui-form-item">
            <label for="quAnswer" class="layui-form-label">
                答案
            </label>
            <div class="layui-input-inline">
                <input type="text" id="quAnswer" name="quAnswer"  th:value="${questionBank.quAnswer}"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="subId" class="layui-form-label">
                学科
            </label>
            <div class="layui-input-inline">
                <select name="subId" id="subId">

                    <option th:each="subject:${subjects}" th:if="${subject.subId} == ${questionBank.subId}" th:value="${subject.subId}">
                        [[${subject.subName}]]
                    </option>
                    <option th:if="${questionBank.subId} == null " th:value="${questionBank.subId}">
                        请输入学科
                    </option>
                    <option th:each="subject:${subjects}" th:value="${subject.subId}" th:text="${subject.subName}">

                    </option>
                </select>
            </div>
        </div>

        <!-- 修改按钮起始位置-->
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="*" lay-submit >
                修改
            </button>
        </div>
        <!-- 修改按钮结束位置-->
    </form>
</div>
<script>
        layui.use(['form','layer'], function() {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer;

            //自定义验证规则
            form.on('submit(*)', function (data) {
                console.log(data);
                $.ajax({
                    url: "/qubank/upqu",
                    type: "post",
                    data: data.field,
                    dataType: "json",
                    success: function (rs) {
                        console.log(rs);
                        if (rs.code == 200){
                            layer.alert(rs.msg, {icon: 6}, function () {
                                // if (rs.success) {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    parent.layer.close(index);
                                    //刷新
                                    parent.window.loadData();
                                // }
                            });
                        }else {
                            layer.open({
                                title: '修改试题信息'
                                ,content: '修改失败!2333333'
                            });
                        }
                    },error:function () {
                        layer.open({
                            title: '系统消息'
                            ,content: '服务器错误!'
                        });
                    }
                })

                return false;
            });
        });
</script>

</body>

</html>